package com.tes;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Setting {

	public List<String> readFile() throws IOException {
		List<String> listSetting = new ArrayList<String>();

		File file = new File(GameResource.savePath + "/"
				+ GameResource.fileName);
		FileInputStream fis = new FileInputStream(file);
		DataInputStream dis = new DataInputStream(fis);
		BufferedReader br = new BufferedReader(new InputStreamReader(dis));
		String data;

		while ((data = br.readLine()) != null) {
			listSetting.add(data);
		}

		dis.close();

		return listSetting;
	}

	public boolean writeFile(List<String> listSetting) throws IOException {
		boolean hasil = false;

		File file = new File(GameResource.savePath + "/"
				+ GameResource.fileName);
		FileWriter fw = new FileWriter(file);
		BufferedWriter bw = new BufferedWriter(fw);
		
		for (String string : listSetting) {
			bw.write(string);
			bw.newLine();
		}
		
		
		return hasil;
	}

}
